import useAxiosApi from '/@/utils/useAxiosApi';
import useApi from '/@/utils/useAxiosApi';
const baseUrl = import.meta.env.VITE_APP_NEW_MODULE_BASE_API;
import axios from "axios";
const token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ4eSI6IjAzIiwicm9sZSI6Ijc2IiwicnlJZCI6IjIwMDE0NjciLCJuYW1lIjoi6LW15YWtIiwidHlwZSI6IjIiLCJleHAiOjE3MTUyNTIzNzN9.2jzlfnWdcddkS8zC8l5KETTSg8661bXSjpIviOhS0cA"; // 替换为你的 JWT Token
const defineUrl = '/tkTable'

/**
 * 查询听课信息
 * @param query
 * @property pageNum 其实页数
 * @property pageSize 每页显示条数
 * @property year 学年
 * @property term 学期
 * @returns {*}
 */
export function getTkRecordListUrl(data){
    return useAxiosApi(baseUrl + defineUrl +`/tkRecordList`, {
        method: 'GET',
        // data: data
        params: data
    });
}

/**
 * 初始化添加听课信息
 * @returns {*}
 */
export function initAddTkUrl() {
    return useAxiosApi(baseUrl + defineUrl +`/initAddTk`, {
        method: 'get',
        data:{}
    })
}

/**
 * 添加听课信息 - 此处不需要做校验，但是又数据必须要
 * @param data
 * @property tcId 要听的课程 id
 * @returns {*}
 */
export function addTkRecordUrl(data) {
    const url = baseUrl + defineUrl + `/addTkRecord`;
    return axios.post(url, data, {
        headers: {
            'Content-Type': 'application/json;charset=utf-8',
            'Authorization': 'Bearer ' + token
        },
    });
}



/**
 * 初始化修改听课信息
 * @param tkId 听课id
 * @returns {*}
 */
export function initUpdateTkUrl(tkId) {
    return useAxiosApi(baseUrl + defineUrl +`/initUpdateTk/${tkId}`,{
        method: 'get',
    })
}

/**
 * 修改听课信息
 * @param data
 * @returns {*}
 */
export function updateTkUrl(data) {
    const url = baseUrl + defineUrl + `/updateTk`;
    return axios.put(url, data, {
        headers: {
            'Content-Type': 'application/json;charset=utf-8',
            'Authorization': 'Bearer ' + token
        },
    });
}

/**
 * 提交听课信息
 * @param data
 * @returns {*}
 */
export function submitTkUrl(data) {
    const url = baseUrl + defineUrl + `/commitTk`;
    return axios.post(url, data, {
        headers: {
            'Content-Type': 'application/json;charset=utf-8',
            'Authorization': 'Bearer ' + token
        },
    });
}

/**
 * 删除听课记录信息
 * @param tkId 听课主键 id
 * @returns {*}
 */
export function deleteTkRecordUrl(tkId) {
    return useAxiosApi(baseUrl + defineUrl +`/deleteTkRecord/${tkId}`,{
        method: 'delete',
    })
}


/**
 * 获取副课老师
 * @param tcId 课程 id
 * @param type 类型
 * @returns {*}
 */
export function getViceTeacher (tcId, type) {
    return useAxiosApi(baseUrl + defineUrl +`/getVice/${tcId}/${type}`,{
        method: 'get',
    })
}

/**
 * 上传图片
 * @param tcId 课程 id
 * @param year 学年
 * @returns {*}
 */
export function getUploadUrlListenClassUrl(tkId, year) {
    const yearEndTwo = year.toString().substring(2)
    return getUPLoadExtUrl(34, 0, tkId, yearEndTwo)
}

export function getUPLoadExtUrl (type, projectId, innerId, subType){
    return `/share/file/uploadExt/${type}/${projectId}/${innerId}/${subType}.mvc`
}

export function submitIamge(url,data){
    return axios.post("/edu_war_exploded" + url, data, {
        headers: {
            "Content-Type": "multipart/form-data",
            'Authorization': 'Bearer ' + token,
        },
    });
}

/**
 * 删除图片
 * @param tcId 课程 id
 * @param year 学年
 * @returns {*}
 */
export function deleteFile(id,name){
    return axios.delete("/edu_war_exploded" + `/share/file/${id}/${name}.mvc`)
}
